package com.store.app.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.store.app.R;
import com.store.app.bean.OpenCardDetailBean;

import java.util.List;

public class MemberOpenCardDetailAdapter extends BaseAdapter {
    private List<OpenCardDetailBean> openCardDetailBeanList;
    private Context context;


    public MemberOpenCardDetailAdapter(List<OpenCardDetailBean> openCardDetailBeanList, Context context) {
        this.openCardDetailBeanList = openCardDetailBeanList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return openCardDetailBeanList.size();
    }

    @Override
    public Object getItem(int position) {
        return openCardDetailBeanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_open_card_deail, null);

            viewHolder.tvTime = (TextView) convertView.findViewById(R.id.tv_time);
            viewHolder.tv_card_no = (TextView) convertView.findViewById(R.id.tv_card_no);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tvTime.setText(openCardDetailBeanList.get(position).getCreated_date()+"");
        viewHolder.tv_card_no.setText(openCardDetailBeanList.get(position).getCard_no()+"");
        return convertView;
    }
    class ViewHolder {
        private TextView tvTime;
        private TextView tv_card_no;
    }
}
